package il.technion.cs236369.webserver.components;

import java.net.URI;
import java.net.URISyntaxException;

import org.apache.http.HttpRequest;
import org.apache.http.HttpServerConnection;

public class WebRequest implements INewWebRequest {

	private HttpServerConnection serverConnection;
	private String relativePath;
	private HttpRequest originalHttpRequest;
	
	public WebRequest(HttpServerConnection connection, HttpRequest httpRequest) throws URISyntaxException{
		
		URI uri = new URI(httpRequest.getRequestLine().getUri());
		String relativePath = uri.getPath();
		
		this.serverConnection = connection;
		this.relativePath = relativePath;
		this.originalHttpRequest =httpRequest;
	}
	
	@Override
	public HttpServerConnection getClientConnection() {
		return serverConnection;
	}

	@Override
	public String getRequestedPath() {
		return relativePath;
	}

	public HttpRequest getHttpRequest() {
		return originalHttpRequest;
	}
}
